home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1995 / MacHack 1995.toast / Presentations / Presentations ’88 / Feldt's Object Stuff / objectMgr stuff / objectMgr.c < prev    next >
Text File  |  1987-04-11  |  1KB  |  80 lines

  1. /*                          Small Systems Guild                                */
  2. /*                               PO box 2751                                    */
  3. /*                             3105 Sunnywood                                    */
  4. /*                        Ann Arbor, Michigan 48103                            */
  5. /*                             (313) 996-4238                                    */
  6.  
  7. /*                   copyright © 1987 Small Systems Guild                         */
  8.  
  9. /*                      source code compilable using                            */
  10. /*                       Lightspeed C compiler 2.01                            */
  11.  
  12. #include    "objectMgr.h"
  13.  
  14. Handle msg(sel,arg)
  15. USHORT        sel;
  16. Handle        arg;
  17. {
  18.     USHORT        result;
  19.     
  20.     result = (USHORT)class_any_object(arg);
  21.     return(_msg(result,sel,arg));
  22. }
  23.  
  24. Handle _msg(obj,sel,arg)
  25. USHORT        obj;
  26. USHORT        sel;
  27. Handle        arg;
  28. {
  29.     USHORT        result;
  30.     
  31.     switch (obj) {
  32.         case UNKNOWN:
  33.             result = (USHORT)class_any_object(arg);
  34.             if (result == UNKNOWN)
  35.                 return(NULL);
  36.             else
  37.                 return(_msg(result,sel,arg));
  38.             break;
  39.         case OBJECT:
  40.             return(Object(sel,arg));
  41.             break;
  42.         case WINDOW:
  43.             return(Window(sel,arg));
  44.             break;
  45.         default:
  46.             return(NULL);
  47.             break;
  48.     }
  49. }
  50.  
  51. Handle class_any_object(argHndl)
  52. Handle        argHndl;
  53. {
  54.     Handle        objHndl;
  55.     USHORT        objClass;
  56.     
  57.     if (!ValidPointer((Ptr)argHndl))
  58.         return(NULL);
  59.  
  60.     objHndl = ((msgArgs *)argHndl)->objHndl;
  61.     if (ValidHandle(objHndl)) {
  62.         if (!((**((object **)objHndl)).sync == OBJ_SYNC)) {
  63.             objHndl = argHndl;
  64.             if (!((**((object **)objHndl)).sync == OBJ_SYNC))
  65.                 return(NULL);
  66.         }
  67.     }
  68.     else {
  69.         objHndl = argHndl;
  70.         if (!((**((object **)objHndl)).sync == OBJ_SYNC))
  71.             return(NULL);
  72.     }
  73.  
  74.     objClass = ((**((object **)objHndl)).isa);
  75.     if (objClass <= 0)
  76.         return(NULL);
  77.     
  78.     return((Handle)objClass);
  79. }
  80.